﻿using System.Collections.Generic;
using System.Linq;
using Shell.DomainDot;
using Framework.Poco;

namespace Framework.Domain
{
    /// <summary>
    /// 经销商文章选择器
    /// </summary>
    public class SelectAgencyArticleByAgency : DomainDotBase<Agency>
    {
        /// <summary>
        /// 经销商的文章
        /// </summary>
        public WithMany<Article> Articles { private get; set; }

        public IEnumerable<Article> GetAllArticles()
        {
            return this.Articles;
        }

        /// <summary>
        /// 获取指定经销商的文章并分页
        /// </summary>
        public IEnumerable<Article> Select(int currentPage, int pageSize, out int total)
        {
            total = this.Articles.Count;
            return this.Articles.Skip((currentPage - 1) * pageSize).Take(pageSize);
        }
    }
}
